package com.example.carconsumer.controller.dl.admin;

import com.alibaba.dubbo.config.annotation.Reference;
import com.example.carinterface.service.dl.admin.ContentService;
import com.example.carinterface.utils.ResultJson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "admin - 内容管理")
@CrossOrigin
@RestController
@RequestMapping("/admin/content")
public class ContentController {

    @Reference(check = false)
    private ContentService contentService;

    //品牌

    @PostMapping("/findAllBrand")
    @ApiOperation("汽车品牌列表")
    public ResultJson<List<Map<String,Object>>> findAllBrand(){

        return contentService.findAllBrand();
    }

    @PostMapping("/addBrand")
    @ApiOperation("添加汽车品牌")
    public ResultJson<String> addBrand(@ApiParam("brand_Name：品牌名称，" +
            "type_Name：型号名称") @RequestBody Map<String,Object> map){
        return contentService.addBrand(map);

    }
    @PostMapping("/updateBrand")
    @ApiOperation("修改汽车品牌")
    public ResultJson<String> updateBrand(@ApiParam("id:品牌id，" +
            "brand_Name：品牌名称，" +
            "type_Name：型号名称") @RequestBody Map<String,Object> map){
        return contentService.updateBrand(map);

    }

    //店铺

    @ApiOperation("店铺列表")
    @PostMapping("/findShop")
    public ResultJson<List<Map<String,Object>>> findShop(@ApiParam("" +
            "shopClass:修理店类型，1 4s点，2 修理厂，3快修店，4检测场，" +
            "fullName：店铺名称（可不传，用于搜索）," +
            "id:店铺id（可不传，用于修改前的查询）") @RequestBody Map<String,Object> map){
        return contentService.findShop(map);
    }

    @ApiOperation("删除店铺")
    @PostMapping("/delShop/{id}")
    public ResultJson<String> delShop( @ApiParam("删除店铺id")@PathVariable("id") Integer id){
        return contentService.delShop(id);
    }

    @ApiOperation("修改店铺")
    @PostMapping("/updateShop")
    public ResultJson<String> updateShop(@ApiParam("id:店铺id，" +
            "fullName：店铺名称，" +
            "abbreviation：店铺简称，" +
            "brand_id：品牌类型id，" +
            "discount：店铺折扣，" +
            "adress：店铺详细地址" +
            "adressCoordinate：地址坐标" +
            "region：所在区域" +
            "state：是否签约，1是，-1否") @RequestBody Map<String,Object> map){

        return contentService.updateShop(map);

    }

    @ApiOperation("添加店铺")
    @PostMapping("/addShop")
    public ResultJson<String> addShop(@ApiParam("\n" +
            "fullName:店铺名称\n" +
            "abbreviation:店铺简称\n" +
            "brand_id:品牌类型id\n" +
            "discount:店铺折扣\n" +
            "adress:店铺详细地址\n" +
            "adressCoordinate:地址坐标\n" +
            "region:所在区域\n" +
            "shopClass:修理店类型，1 4s点，2 修理厂，3快修店，4检测场，\n" +
            "state:是否签约，1是，-1否") @RequestBody Map<String,Object> map){

        return contentService.addShop(map);
    }










}
